package com.foreveross.crawl.common.application;

import java.util.List;

import com.foreveross.crawl.common.exception.BusinessException;
import com.foreveross.crawl.common.exception.TaskStateException;
import com.foreveross.crawl.dto.TaskModelDto;
import com.foreveross.crawl.vo.TaskStatisticsVO;

public interface ITaskModelEntityApplication {

	public List<TaskModelDto> getTaskModelByTaskId(String taskId);
	
	public List<TaskModelDto> getTaskModelByChannelId(Long channelId);
	
	public List<TaskModelDto> getAllTaskModel();
	
	public void addTaskModel(TaskModelDto dto);
	
	/**  
	 * @Description: 更新任务状态
	 * @param taskId
	 * @param state
	 * @author luofangyi
	 * @date 2014-10-9 下午6:05:19 
	 */ 
	public void updateTaskState(String taskId, String state) throws TaskStateException;
	
	/**  
	 * @Description: 更新开始
	 * @param taskId
	 * @param dateStr
	 * @author luofangyi
	 * @date 2014-10-10 下午2:51:15 
	 */ 
	public void updateTaskStartDate(String taskId, String dateStr) throws TaskStateException;
	
	/**  
	 * @Description: 更新任务结束时间、执行时间
	 * @param channelId
	 * @param taskId
	 * @param excuteTime
	 * @param isStateFinished
	 * @throws TaskStateException
	 * @author luofangyi
	 * @date 2014-10-10 下午3:04:28 
	 */ 
	public void updateTaskEndDateAndExcuteTime(Long channelId, String taskId, long excuteTime, boolean isStateFinished) throws TaskStateException, BusinessException;
	
	/**  
	 * @Description: 根据任务ID记录轨迹信息
	 * @param taskId
	 * @param track
	 * @throws TaskStateException
	 * @author luofangyi
	 * @date 2014-10-10 下午3:12:55 
	 */ 
	public void recordTracksOfTask(String taskId, String track) throws TaskStateException;
	
	public List<TaskModelDto> getTaskModelByChannelIdAndState(Long channelId, String state);
	
	public void deleteValidTaskModel();
	
	public void deleteAllTaskModel();
	
	public int countAllTaskModel();
	
	public int countSuccessTaskModel(Long channelId);
	
	public int countDoingTaskModel(Long channelId);
	
	public int countException(Long channelId);
	
	/**  
	 * @Description: 分组统计渠道下不同状态下任务信息
	 * @return
	 * @author luofangyi
	 * @date 2014-10-11 下午4:39:11 
	 */ 
	public List<TaskStatisticsVO> statisticsTask();
	
	public int countTaskModelByChannelIdAndState(Long channelId, String state);
}
